﻿module Sustainalytics.EsgRatings {
    export class KeyESGIssuesService implements IKeyESGIssuesService {
        private $q: ng.IQService;
        private $http: ng.IHttpService;
        private notificationFactory: INotificationFactory;
        private staticObjects: IStaticObjects;
        private $upload: any;

        constructor($q: ng.IQService, $http: ng.IHttpService, notificationFactory: INotificationFactory, staticObjects: IStaticObjects, $upload) {
            this.$q = $q;
            this.$http = $http;
            this.notificationFactory = notificationFactory;
            this.staticObjects = staticObjects;
            this.$upload = $upload;
        }

        public uploadKeyESGIssuesFile(dataFile: ArrayBuffer, fileName: string, contentType: string) {
            return this.$upload.http({
                url: "/esgratingserv/api/v1/esgratings/keyesgissues",
                headers: { "Content-Type": contentType, "Content-Disposition": "attachment; filename=\"" + fileName + "\"" },
                data: dataFile
            });
        }
    }

    // register service with EsgRatings Angular module
    angular.module('Sustainalytics.EsgRatings').factory('KeyESGIssuesService', ($q: ng.IQService, $http: ng.IHttpService, notificationFactory: INotificationFactory, staticObjects: IStaticObjects, $upload) => new KeyESGIssuesService($q, $http, notificationFactory, staticObjects, $upload));
}